#include "StdAfx.h"
#include "UICommon.h"

BOOL BrowseFile(HWND hParent, LPCTSTR szFilter, LPCTSTR szTitle, CStdString& strFile)
{
	OPENFILENAME sOpenFile;
	TCHAR szSelectedFile[MAX_PATH] = { 0 };
	::ZeroMemory(&sOpenFile, sizeof(OPENFILENAME));
	sOpenFile.lStructSize = sizeof(OPENFILENAME);
	sOpenFile.hwndOwner = hParent;
	sOpenFile.lpstrFilter = szFilter;
	sOpenFile.lpstrFile = szSelectedFile;
	sOpenFile.nMaxFile = MAX_PATH;
	sOpenFile.lpstrTitle = szTitle;
	sOpenFile.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST;

	if(::GetOpenFileName(&sOpenFile))
	{
		strFile = szSelectedFile;
		return TRUE;
	}

	return FALSE;
}

extern CMainWnd* g_pMainWnd;

CMainWnd* GetMainWnd()
{
	return g_pMainWnd;
}